package com.healthguide.backend.repository;

import com.healthguide.backend.entity.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ArticleRepository extends JpaRepository<Article, Long> {
    
    List<Article> findByCategoryOrderByCreatedAtDesc(String category);
    
    @Query("SELECT a FROM Article a ORDER BY a.readCount DESC LIMIT 10")
    List<Article> findTop10ByOrderByReadCountDesc();
}
